<template>
	<view class="cu-bar tabbar fixedposition">
		<view class="action" @click="navTo(item.pagePath)" v-for="(item,index) in routerList" :key="index">
			<view class="cuIcon-cu-image">
				<image :src="current==item.id?item.selectedIconPath:item.iconPath" mode="widthFix"></image>
			</view>
			<view class="cu-tag badge" v-if="item.id==2&&num"  style="top: 0upx;right: 50upx;">{{num}}</view>
			<view :class="current==item.id?'':'text-gray'" style="line-height: 36upx;font-size: 24upx;">{{item.text}}</view>
		</view>
	</view>	
</template>

<script>
	import {
	    mapState,
	} from 'vuex';
	export default {
		props:{
		  current: {
			type: [Number,String],
			default:1
		  }
		},
		computed:{
			...mapState(['wdnumber']),
		},	
		data() {
			return {
				routerList:[{
					id:1,
					"text":"签到",
					"pagePath": "/pages/index/index?ishow=1",
					"iconPath": "/static/footer-qd.png",
					"selectedIconPath": "/static/footer-qdhover.png",
				},{
					id:2,
					"text":"消息",
					"pagePath": "/pages/message/message2",
					"iconPath": "/static/footer-xx.png",
					"selectedIconPath": "/static/footer-xxhover.png",
				},{
					id:3,
					"text":"我的",
					"pagePath": "/pages/my/my",
					"iconPath": "/static/footer-wd.png",
					"selectedIconPath": "/static/footer-wdhover.png",
				}],
				num:null
			};
		},
		methods: {
			navTo(url){
				uni.redirectTo({
					url
				})
			}, 	
			cartNumber(){
				let cart = this.$ComFunJS.getStorage('tcart');
				let num = 0;
				cart.then((res)=>{
					if(res){
						JSON.parse(res).forEach((a)=>{
							num+=a.qtynum;
						});
					}else{
				
					}
					this.num = num
				})
			},
		},
		mounted() {
			this.cartNumber()
		}
	}
</script>

<style>
	.fixedposition{
		box-sizing: border-box;
		position: fixed;
		left: 0;
		bottom: 0;
		width: 100%;
		z-index: 998;
		height: 118upx;
		overflow:hidden;
		justify-content: space-between;
		border-radius: 40upx 40upx 0px 0px;
		background: #FFFFFF;
		box-shadow: 0px 0px 18px 0px rgba(0, 0, 0, 0.13);
	}
	.boxShowTop{
		box-shadow: 0 10upx 40upx 5upx rgba(128,135,143,0.14);
	}
</style>
